#
# Copyright 2008 Wepoco.  http://www.wepoco.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from google.appengine.api import users


def short_header(request):
  return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<style type="text/css">/* <![CDATA[ */
.bottombar { float:none; } 
.msg {background-color:#ffffff; padding:2px; border-bottom:1px solid #bbb;} 
.msgrd {background-color:#E8EEF7; padding:2px; border-bottom:1px solid #bbb;} 
body {background-color:#ffffff; font-family:sans-serif;margin:0px;} 
.bkg {background-color:#C3D9FF; padding:3px;} .check {} .checklbl{} 
.gray {color:gray;} 
.nav {padding: 2px;} 
.hdr {background-color:#efefef; padding: 2px;} 
.navlnk {}/* ]]> */
</style>"""

def banner(request):
  return """<p><big><b>PxTrax</b></big><br />
<a href="/">my tracks</a>&nbsp;|&nbsp;
<a href="/shared">shared tracks</a>&nbsp;|&nbsp;
<a href="/about">about</a>&nbsp;|&nbsp;
<a href="/help">help</a></p>
"""

def header(request):
  return short_header(request) + banner(request) 

def footer(request):
  if users.GetCurrentUser():
      login_url = users.CreateLogoutURL(request.uri)
      login_linktext = 'Sign out'
      login_name = users.GetCurrentUser().email()
  else:
    login_url = users.CreateLoginURL(request.uri)
    login_linktext = 'Sign in'
    login_name = 'Not logged in'
    pass
  return """<p><a href="%s">%s</a> %s</p>
<img src="http://code.google.com/appengine/images/appengine-noborder-120x30.gif" 
alt="Powered by Google App Engine" />
</body></html>""" % (login_url,login_linktext,login_name)



